<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item>
        <el-button type="primary" size="small" @click="editSetting()" plain>新增班次</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="teamlist" size="small">
      <el-table-column label="班次名称" prop="name"/>
      <el-table-column label="考勤时间" prop="phone">
        <template slot-scope="scope">
          {{ `${scope.row.comeTime1}-${scope.row.outNext1 ? '次日' : ''}${scope.row.outTime1} ${scope.row.comeTime2 && scope.row.comeNext2 ? '次日' : ''}${scope.row.comeTime2 || ''}${scope.row.comeTime2 ? '-' : ''}${scope.row.outTime2 && scope.row.outNext2 ? '次日' : ''}${scope.row.outTime2 || ''}` }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="130">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="editSetting(scope.row.id)"
            v-hasPermi="['system:stagnation_point:edit']"
          >编辑
          </el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="deletUser(scope.row)"
            v-hasPermi="['system:stagnation_point:edit']"
          >删除
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
<!--    <pagination-->
<!--      v-show="total>0"-->
<!--      :total="total"-->
<!--      :page.sync="queryParams.pageNum"-->
<!--      :limit.sync="queryParams.pageSize"-->
<!--      :layout="layout"-->
<!--      @pagination="getList"-->
<!--    />-->
    <setting :visible.sync="settingVisible" :param="pointData" @getList="getList"></setting>
  </div>
</template>

<script>
import {listSignCate, delSignCate} from "@/api/system/sign_category";
import setting from "@/components/classes/setting"

export default {
  name: "index",
  props: ['pointData', 'type', 'pointId'], // param 执勤点信息
  components: {setting},
  data() {
    return {
      teamlist: [],
      detailvisible: false,
      title: '班次管理',
      // 遮罩层
      loading: true,
      // 选中数组
      layout: 'total, sizes, prev, pager, next',
      // 总条数
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        pointsId: ''
      },
      settingVisible: false,
      paramId: 0
    }
  },
  watch: {
  },
  created() {
    // this.queryParams.pointsId = this.$route.params && this.$route.params.pointId;
    if (this.type == 'homeindex') {
      this.queryParams.pointsId = this.pointId;
    } else {
      this.queryParams.pointsId = this.$route.params && this.$route.params.pointId;
    }
    console.log('this.type:', this.type, this.pointId)
    this.getList()
  },
  methods: {
    editSetting(id) {
      this.settingVisible = true
    },
    /** 查询定位器列表 */
    getList() {
      this.loading = true;
      listSignCate(this.queryParams).then(response => {
        this.teamlist = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    deletUser(row) {
      this.$modal
        .confirm(`确定将该班次移除,是否继续？`)
        .then(function () {
          return delSignCate(row.id);
        })
        .then(() => {
          this.$modal.msgSuccess("移除成功");
          this.getList()
        })
        .catch(() => {
        });
    },
    cancel() {
      this.$emit('update:visible', false)
    },
  }
}
</script>

<style scoped>

</style>
